package com.ruoyi.qualification.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.firefighter.domain.FirefighterInfo;
import com.ruoyi.firefighter.service.IFirefighterInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.qualification.mapper.FirefighterQualificationMapper;
import com.ruoyi.qualification.domain.FirefighterQualification;
import com.ruoyi.qualification.service.IFirefighterQualificationService;

/**
 * 专业资质Service业务层处理
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Service
public class FirefighterQualificationServiceImpl implements IFirefighterQualificationService
{
    @Autowired
    private FirefighterQualificationMapper firefighterQualificationMapper;
    @Autowired
    private IFirefighterInfoService iFirefighterInfoService;
    /**
     * 查询专业资质
     *
     * @param id 专业资质主键
     * @return 专业资质
     */
    @Override
    public FirefighterQualification selectFirefighterQualificationById(Long id)
    {
        return firefighterQualificationMapper.selectFirefighterQualificationById(id);
    }

    /**
     * 查询专业资质列表
     *
     * @param firefighterQualification 专业资质
     * @return 专业资质
     */
    @Override
    public List<FirefighterQualification> selectFirefighterQualificationList(FirefighterQualification firefighterQualification)
    {
        return firefighterQualificationMapper.selectFirefighterQualificationList(firefighterQualification);
    }

    /**
     * 新增专业资质
     *
     * @param firefighterQualification 专业资质
     * @return 结果
     */
    @Override
    public int insertFirefighterQualification(FirefighterQualification firefighterQualification)
    {
        FirefighterInfo firefighterInfo1 = new FirefighterInfo();
        firefighterInfo1.setIdCardNumber(firefighterQualification.getFirefighterIdCard());
        FirefighterInfo firefighterInfo= iFirefighterInfoService.selectFirefighterInfoBySfz(firefighterInfo1);
        firefighterQualification.setFirefightId(firefighterInfo.getUserId());
        firefighterQualification.setCreateTime(DateUtils.getNowDate());
        return firefighterQualificationMapper.insertFirefighterQualification(firefighterQualification);
    }

    /**
     * 修改专业资质
     *
     * @param firefighterQualification 专业资质
     * @return 结果
     */
    @Override
    public int updateFirefighterQualification(FirefighterQualification firefighterQualification)
    {
        firefighterQualification.setUpdateTime(DateUtils.getNowDate());
        return firefighterQualificationMapper.updateFirefighterQualification(firefighterQualification);
    }

    /**
     * 批量删除专业资质
     *
     * @param ids 需要删除的专业资质主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterQualificationByIds(Long[] ids)
    {
        return firefighterQualificationMapper.deleteFirefighterQualificationByIds(ids);
    }

    /**
     * 删除专业资质信息
     *
     * @param id 专业资质主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterQualificationById(Long id)
    {
        return firefighterQualificationMapper.deleteFirefighterQualificationById(id);
    }

    @Override
    public List<FirefighterQualification> selectFirefighterQualificationListByUserid(String userId) {
        return  firefighterQualificationMapper.selectFirefighterQualificationListByUserid(userId);
    }

    @Override
    public void deleteFirefighterQualificationById1(Long userId) {
        firefighterQualificationMapper.deleteFirefighterQualificationByIduser(userId);
    }


}
